.TH puts 3 "" "" ""
.SH SYNOPSIS
puts \- write a character string
.SH ANSI_SYNOPSIS
#include <stdio.h>
.br
int puts(const char *
.IR s );
.br

int _puts_r(void *
.IR reent ,
const char *
.IR s );
.br
.SH TRAD_SYNOPSIS
#include <stdio.h>
.br
int puts(
.IR s )
.br
char *
.IR s ;
.br

int _puts_r(
.IR reent ,
.IR s )
.br
char *
.IR reent ;
.br
char *
.IR s ;
.br
.SH DESCRIPTION
.BR puts 
writes the string at 
.IR s 
(followed by a newline, instead of
the trailing null) to the standard output stream.

The alternate function 
.BR _puts_r 
is a reentrant version. The extra
argument 
.IR reent 
is a pointer to a reentrancy structure.
.SH RETURNS
If successful, the result is a nonnegative integer; otherwise, the
result is 
.BR EOF .
.SH PORTABILITY
ANSI C requires 
.BR puts ,
but does not specify that the result on
success must be 
.BR 0 ;
any non-negative value is permitted.

Supporting OS subroutines required: 
.BR close ,
.BR fstat ,
.BR isatty ,
.BR lseek ,
.BR read ,
.BR sbrk ,
.BR write .
*/

#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "%W% (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */

#include <stdio.h>
#include <string.h>
#include "fvwrite.h"

/*
* Write the given string to stdout, appending a newline.
*/

int
_DEFUN (_puts_r, (ptr, s),
struct _reent *ptr _AND
_CONST char * s)
{
size_t c = strlen (s);
struct __suio uio;
struct __siov iov[2];

iov[0].iov_base = s;
iov[0].iov_len = c;
iov[1].iov_base = "\n";
iov[1].iov_len = 1;
uio.uio_resid = c + 1;
uio.uio_iov = &iov[0];
uio.uio_iovcnt = 2;

return (__sfvwrite (_stdout_r (ptr), &uio) ? EOF : '\n');
}

#ifndef _REENT_ONLY

int
_DEFUN (puts, (s),
char _CONST * s)
{
return _puts_r (_REENT, s);
}

#endif
.SH SOURCE
src/newlib/libc/stdio/puts.c
